layui.use(['layer', 'form', 'admin', 'ax', 'upload', 'laydate'], function () {
    var $ = layui.jquery;
    var $ax = layui.ax;
    var form = layui.form;
    var admin = layui.admin;
    var layer = layui.layer;
    var upload = layui.upload;
    var laydate = layui.laydate;
    //渲染时间选择框
    laydate.render({
        elem: '#loanDate',
        value: new Date(),
        tiger: 'click'
    });

    /**
     * 检索借款人
     */
    var languageAjax = new $ax(Feng.ctxPath + "/flowInfo/borrowerInfo");
    var languageResult = languageAjax.start();

    $.each(languageResult, function (index, val) {
        $("#borrowerId").append("<option value='" + val.id + "'>" + val.name + "</option>");
    });
    form.render('select');


    // 表单提交事件
    form.on('submit(btnSubmit)', function (data) {
        var ajax = new $ax(Feng.ctxPath + "/flowInfo/addFq", function (data) {
            Feng.success("添加成功！");

            //传给上个页面，刷新table用
            admin.putTempData('formOk', true);

            //关掉对话框
            admin.closeThisDialog();

        }, function (data) {
            Feng.error("添加失败！" + data.responseJSON.message)
        });
        ajax.set(data.field);
        ajax.start();
        //添加 return false 可成功跳转页面
        //admin.putTempData('formOk', true);
        //.$("#borrowerId").val(data.field.borrowerId);
        return false;
    });

});